package vista;
import controlador.*;

public class VistaCambiarPartes extends javax.swing.JFrame {
   
	private static final long serialVersionUID = 1L;
	
	private javax.swing.JButton botonRemplazar;
    private javax.swing.JButton botonVolver;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JList listaPartesNuevas;
    private javax.swing.JList listaPartesUsadas;

	
	
    public VistaCambiarPartes(ControladorCambiarPartes controlador) {
        initComponents();
        this.VistaCambiarPartesVisibilidadTrue();
        this.setLocationRelativeTo(null); 
        listaPartesNuevas.addListSelectionListener(controlador.getListenerListaPartesNuevas());
        listaPartesUsadas.addListSelectionListener(controlador.getListenerListaPartesUsadas());
        botonRemplazar.addActionListener(controlador.getListenerBotonRemplazar());
        botonVolver.addActionListener(controlador.getListenerBotonVolver());
    }
    
    public void VistaCambiarPartesVisibilidadFalse(){
		this.setVisible(false);
    } 
    
    public void VistaCambiarPartesVisibilidadTrue(){
		this.setVisible(true);
	}
     private void initComponents() {

        jLabel2 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        listaPartesNuevas = new javax.swing.JList();
        jScrollPane2 = new javax.swing.JScrollPane();
        listaPartesUsadas = new javax.swing.JList();
        botonRemplazar = new javax.swing.JButton();
        botonVolver = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Car Tunning Experience 2008");
        
        jLabel2.setFont(new java.awt.Font("Comic Sans MS", 0, 24));
        jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel2.setText("CAMBIAR PARTES");

        jScrollPane1.setViewportView(listaPartesNuevas);

        jScrollPane2.setViewportView(listaPartesUsadas);

        botonRemplazar.setText("REMPLAZAR");

        botonVolver.setText("VOLVER");
        

        jLabel1.setText("PARTES NUEVAS");

        jLabel3.setText("PARTES USADAS");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(60, Short.MAX_VALUE)
                .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 259, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(54, 54, 54))
            .addGroup(layout.createSequentialGroup()
                .addGap(38, 38, 38)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 114, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(layout.createSequentialGroup()
                                .addGap(12, 12, 12)
                                .addComponent(botonRemplazar)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 67, Short.MAX_VALUE)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jScrollPane2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                .addComponent(botonVolver)
                                .addGap(19, 19, 19))))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 98, Short.MAX_VALUE)
                        .addComponent(jLabel3)
                        .addGap(10, 10, 10)))
                .addGap(44, 44, 44))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(26, 26, 26)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(jLabel3))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 192, Short.MAX_VALUE)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 192, Short.MAX_VALUE))
                .addGap(27, 27, 27)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(botonRemplazar)
                    .addComponent(botonVolver))
                .addContainerGap())
        );

        pack();
    }

        
      
     public int DevolverIndicePartesNuevas (){
 	   return listaPartesNuevas.getSelectedIndex();
     }
     
     public int DevolverIndicePartesUsadas (){
  	   return listaPartesUsadas.getSelectedIndex();
     }
     
    public void llenarListaPartesNuevas (javax.swing.DefaultListModel modelo){
    	listaPartesNuevas.setModel(modelo);
    }
    
    public void llenarListaPartesUsadas (javax.swing.DefaultListModel modelo){
    	listaPartesUsadas.setModel(modelo);
    }
        
}
